package lxs.tool.liberator.work.controller;

import lxs.tool.liberator.common.base.result.Response;
import lxs.tool.liberator.work.pojo.Interface;
import lxs.tool.liberator.work.service.InterfaceService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("work/interface")
public class InterfaceController {
    @Autowired
    private InterfaceService interfaceService;

    @GetMapping("showTable")
    public Response showTable() throws Exception {
        return interfaceService.showTable();
    }

    @GetMapping("download")
    public Response download(String id, HttpServletResponse response) throws Exception {
        return interfaceService.download(response, id);
    }

    @GetMapping("getOptions")
    public Response getOptions() {
        return interfaceService.getOptions();
    }

    @GetMapping("getById")
    public Response getById(String id) {
        return interfaceService.getById(id);
    }

    @GetMapping("deleteById")
    public Response deleteById(String id) {
        return interfaceService.deleteById(id);
    }

    @PostMapping("insert")
    public Response insert(@RequestBody Interface in) {
        return interfaceService.insert(in);
    }

    @PostMapping("update")
    public Response update(@RequestBody Interface in) {
        return interfaceService.update(in);
    }
}
